﻿using System;
using Rodunu.Movies.Services.Models.Netflix.Attributes;
using Rodunu.Movies.Services.Models.Netflix.Enums;

namespace Rodunu.Movies.Services.Models.Netflix
{
    public partial class QueueItem : Item
    {
        public DateTime? AvailabileDate { get; set; }

        [XPath("/queue_item/position/text()")]
        public int Position { get; set; }

        [XPath("/queue_item/category[@scheme='http://api.netflix.com/categories/queue_availability' or @scheme='http://api.netflix.com/categories/queue_availablity']/@label")]
        public Availability Availability { get; set; }

        [XPath("/queue_item/availability_date/text()")]
        public long AvailabilityDate
        {
            set
            {
                AvailabileDate = new DateTime(1970, 1, 1).AddSeconds(value);
            }
        }

        [XPath("/queue_item/updated/text()")]
        public long Updated { get; set; }

        [XPath("/queue_item/category[@scheme='http://api.netflix.com/categories/title_formats']/@label")]
        public Format Format { get; set; }

        [XPath("/queue_item/link[@rel='http://schemas.netflix.com/catalog/title']")]
        public Link TitleLink { get; set; }

        public override string TitleRef
        {
            get { return TitleLink.Href; }
        }
    }
}